package org.scboy.dbms.valid.datatype;

import java.util.List;

import org.scboy.dbms.annotation.ValidType;
import org.scboy.dbms.entity.ParamConfig;
import org.scboy.dbms.valid.Valid;
import org.scboy.dbms.valid.common.RegxValid;
import org.scboy.utils.entitys.coobi.Model;


@ValidType("IP地址")
public class IPValid extends RegxValid implements Valid {
	@Override
	public List<ParamConfig> config() {
		return null;
	}
	
	@Override
	public String toString(Model config) {
		return "IP地址格式不正确";
	}
	
	@Override
	public boolean valid(Object value,Model model, Model config) {
		String num = "(25[0-5]|2[0-4]\\d|[0-1]\\d{2}|[1-9]?\\d)";
		String regex = "^" + num + "\\." + num + "\\." + num + "\\." + num + "$";
		config=Model.create();
		config.put("expression", regex);
		return super.valid(value,model, config);
	}
}
